<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/resources/jstl_contexpath.jsp"%>
<!DOCTYPE html>
<html>
<head>
    <title>虎丘婚纱城管理系统</title>
    <link rel="stylesheet" type="text/css" href="<c:url value="/resources/bs3/css/bootstrap.min.css" />" />
    <link rel="stylesheet" type="text/css" href="<c:url value="/resources/css/bootstrap-reset.css" />" />
    <link rel="stylesheet" type="text/css" href="<c:url value="/resources/font-awesome/css/font-awesome.css" />" />
    <link rel="stylesheet" type="text/css" href="<c:url value="/resources/css/clndr.css" />" />
    <link rel="stylesheet" type="text/css" href="<c:url value="/resources/css/style.css" />" />
    <link rel="stylesheet" type="text/css" href="<c:url value="/resources/css/style-responsive.css" />" />

    <!-- start: CSS -->
    <link rel="stylesheet" type="text/css" href="<c:url value="/resources/assets/css/bootstrap.min.css" />" />
    <link rel="stylesheet" type="text/css" href="<c:url value="/resources/assets/css/style.min.css" />" />
    <link rel="stylesheet" type="text/css" href="<c:url value="/resources/assets/css/retina.min.css" />" />
    <!-- end: CSS -->

    <!-- start: Favicon and Touch Icons -->
    <link rel="apple-touch-icon-precomposed" sizes="144x144" href="<c:url value="/resources/assets/ico/apple-touch-icon-144-precomposed.png" />" />
    <link rel="apple-touch-icon-precomposed" sizes="114x114" href="<c:url value="/resources/assets/ico/apple-touch-icon-114-precomposed.png" />" />
    <link rel="apple-touch-icon-precomposed" sizes="72x72" href="<c:url value="/resources/assets/ico/apple-touch-icon-72-precomposed.png" />" />
    <link rel="apple-touch-icon-precomposed" sizes="57x57" href="<c:url value="/resources/assets/ico/apple-touch-icon-57-precomposed.png" />" />
    <link rel="shortcut icon" href="<c:url value="/resources/assets/ico/favicon.png" />" />
    <!-- end: Favicon and Touch Icons -->

    <link rel="stylesheet" href="<c:url value="/resources/css/base.css" />" />
    <link rel="stylesheet" href="<c:url value="/resources/css/hq.css" />" />

</head>
<body>

<!-- start: Header -->
<%@ include file="/resources/head.jsp" %>
<!-- end: Header -->

<div class="container">
    <div class="row">
        <!-- start: Main Menu -->
        <%@ include file="/resources/sidebar.jsp" %>
        <!-- end: Main Menu -->

        <!-- start: Content -->
        <div id="content" class="col-lg-10 col-sm-11" style="min-height: 800px">
            <div class="form-top">
                <form action="${ctx}/manage/activity/index" method="post" class="form-inline form-group form-post">
                    <div class="form-group">
                        <input type="text" class="form-control ng-pristine ng-untouched ng-valid" style="margin-left: -24px" placeholder="活动名称" name="activity_name" id="activity_name" value="${activity_name}">
                    </div>
                    <div class="form-group" style="margin-left: -14px">
                        <button type="submit" class="btn btn-primary">
                            <span class="btn-icon-text">搜索</span>
                        </button>
                    </div>

                </form>
                <div class="form-group">
                    <select id="activity_type" name="activity_type" class="form-control" onchange="activityType()">
                        <option value="-1" >--选择活动类型--</option>
                        <option value="0" <c:if test="${activity_type == 0}">selected</c:if>>报名</option>
                        <option value="1" <c:if test="${activity_type == 1}">selected</c:if>>投票评选</option>
                        <option value="2" <c:if test="${activity_type == 2}">selected</c:if>>优惠券</option>
                        <option value="3" <c:if test="${activity_type == 3}">selected</c:if>>抽奖</option>
                        <option value="4" <c:if test="${activity_type == 4}">selected</c:if>>定制小游戏</option>
                    </select>
                </div>
                <div class="form-group">
                    <select id="orderby" name="orderby" class="form-control" onchange="orderby()">
                        <option value="">--选择排序方式--</option>
                        <option value="signup_count,asc" <c:if test="${orderby == 'signup_count,asc'}">selected</c:if>>按报名人数升序</option>
                        <option value="signup_count,desc" <c:if test="${orderby == 'signup_count,desc'}">selected</c:if>>按报名人数降序</option>
                    </select>
                </div>
                <div class="form-group">
                    <button type="button" class="btn btn-success" id="batchexport">
                        <i class="icon-base icon-24 icon-btn-templateload"></i>
                        <span class="btn-icon-text">批量导出</span>
                    </button>
                    <button type="button" class="btn btn-primary" id="addnew">
                        <i class="icon-base icon-24 icon-btn-add"></i>
                        <span class="btn-icon-text">新增活动</span>
                    </button>
                </div>
            </div>
            <div class="row">
                <div class="col-lg-12">
                    <div class="box">
                        <div class="box-header">
                            <h2><i class="fa fa-align-justify"></i><span class="break"></span>活动列表</h2>
                            <div class="box-icon">
                            </div>
                        </div>
                        <div class="box-content">
                            <div class="box-area">
                                <ul class="item-lists">
                                <c:forEach var="activity" items="${activity_list}" varStatus="status">
                                    <li class="item" data-actid="${activity.id}">
                                        <a class="checkbox"></a>
                                        <div class="item-box">
                                            <div class="item-img">
                                                <a href="${ctx}/manage/activity/detail?aid=${activity.id}"><img src="${ctx}/${activity.cover_url}" alt=""></a>
                                            </div>
                                            <div class="item-title">${activity.name}</div>
                                            <div class="item-subtitle">
                                                <c:if test="${activity.type == 0}">
                                                    报名
                                                </c:if>
                                            </div>
                                            <div class="item-time">
                                                <i class="start">${activity.begin_time}</i>~<i class="end">${activity.end_time}</i>
                                            </div>
                                        </div>
                                    </li>
                                </c:forEach>
                                </ul>
                            </div>
                            <%@ include file="/resources/page.jsp"%>
                        </div>
                    </div>
                </div><!--/col-->
            </div>
        </div>
    </div>
</div>
<%@ include file="/resources/managerfoot.jsp"%>

<!-- start: JavaScript-->
<script type="text/javascript" src="<c:url value="/resources/assets/js/jquery-2.1.0.min.js" />" ></script>
<script type="text/javascript" src="<c:url value="/resources/assets/js/jquery-migrate-1.2.1.min.js" />" ></script>
<script type="text/javascript" src="<c:url value="/resources/assets/js/bootstrap.min.js" />" ></script>

<!-- page scripts -->
<script type="text/javascript" src="<c:url value="/resources/assets/js/jquery-ui-1.10.3.custom.min.js" />" ></script>
<script type="text/javascript" src="<c:url value="/resources/assets/js/jquery.sparkline.min.js" />" ></script>
<script type="text/javascript" src="<c:url value="/resources/assets/js/jquery.dataTables.min.js" />" ></script>
<script type="text/javascript" src="<c:url value="/resources/assets/js/dataTables.bootstrap.min.js" />" ></script>

<!-- theme scripts -->
<script type="text/javascript" src="<c:url value="/resources/assets/js/custom.min.js" />" ></script>
<script type="text/javascript" src="<c:url value="/resources/assets/js/core.min.js" />" ></script>

<!-- inline scripts related to this page -->
<script type="text/javascript" src="<c:url value="/resources/assets/js/pages/table.js" />" ></script>

<!-- end: JavaScript-->
<script>
    $('#addnew').click(function(){
        window.location.href="${ctx}/manage/activity/choosetemp";
    });
    $('.modify').click(function(){
        var edited_user_id = $(this).val();
        window.location.href="${ctx}/manage/activity/edit?edited_activity_id="+edited_activity_id;
    })
    $('.delete').click(function(){
        if(confirm("确定要删除吗？")) {
            var edited_activity_id = $(this).val();
            alert(edited_activity_id);
            <%--$.ajax({--%>
            <%--url:"${ctx}/manage/system/user/dodelete",--%>
            <%--type: "post",--%>
            <%--data:{edited_user_id:edited_user_id},--%>
            <%--success:function(data){--%>
            <%--if(data > 0){--%>
            <%--alert("成功");--%>
            <%--location.reload();--%>
            <%--} else {--%>
            <%--alert("失败");--%>
            <%--return false;--%>
            <%--}--%>
            <%--}--%>
            <%--})--%>
        }
    })

    function activityType() {
        var activity_type = $('#activity_type option:selected').val();
        window.location.href="${ctx}/manage/activity/index?activity_type="+activity_type;
    }

    function orderby() {
        var orderby = $('#orderby option:selected').val();
        window.location.href="${ctx}/manage/activity/index?orderby="+orderby;
    }

    // checkbox
    $(".item-lists").on('click','.item a.checkbox',function(){
        var _ = $(this);
        _.hasClass('checked') ? _.removeClass('checked') : _.addClass('checked');
    });
    // 导出
    $('#batchexport').on('click',function(){
        var activityArr=[];// 活动id数组
        actStr =""; // 活动id字符串
        $(".item-lists").find('.item').each(function(){
            var $item = $(this),
                    id = $item.attr('data-actid'),
                    $checkbox = $item.find('a.checkbox');
            if($checkbox.hasClass('checked')){
                activityArr.push(id);
            }
        });
        if(activityArr.length<1){
            alert('请先勾选活动再导出!');
            return;
        }
        actStr = activityArr.join(',');
        window.location.href="${ctx}/manage/activity/export?activity_ids="+actStr;
    });
</script>
</body>
</html>